<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>精选板块轮动</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">						
			#towriter{
				margin-top:-15px;
				border: 1px solid #555555;
				height:100%;				
			}			
			.fixedBox{
				border:none;
				white-space: nowrap;
			}
			.fixedBox::-webkit-scrollbar {
				width: 10px;     
				height: 10px;				
			}			
			p {margin-top:0px;margin-bottom:5px}				
			
			table{
				width:100px; 
				border-collapse:collapse; 
				text-align:center;
			}
			td,th{border:1px solid #696969}
			th { 
				color:#E5E5E5;  <!-- 表头文字颜色 -->
			}
			td a:link{
				color:#E5E5E5;  <!-- 列表文字颜色 -->
			}	
			
			#bar, #bar1{
				padding-top: 1px;
				height: 25px;								
				background-color: #666;
				<!-- cursor: move; -->
			}			
			
			#content, #content1{				
				height: 450px;
				background-color: #000;  <!-- 弹出框背景色 -->
				white-space: nowrap;
				overflow:auto;				
			}
			
			#content::-webkit-scrollbar, #content1::-webkit-scrollbar{
				width: 12px;     
				height: 12px;
				scrollbar-arrow-color:white;
				background-color: #E5E5E5;		
			}
			#content::-webkit-scrollbar-thumb, #content1::-webkit-scrollbar-thumb{
				border-radius: 5px;
				-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
				background: rgba(0,0,0,0.2);
				scrollbar-arrow-color:#555;
			}
			#content::-webkit-scrollbar-track, #content1::-webkit-scrollbar-track {
				-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
				border-radius: 0;
				background: rgba(0,0,0,0.1);
			}
		</style>
	</head>
	<body>		
		<div id="towriter" class="fixedBox" style="display:none;">
			<div id="title" style="margin:10px 50px -5px 5px;"></div>
			<div style="position:relative;float:left;width:66%;">
				<div id="towrites" style="position:relative;float:left;width:98%;"></div>									
				<div id="towritets" style="position:relative;float:left;margin-left:5px;width:97%;"></div>
				<div id="charts3" style="position:relative; float:left;margin:0px 0px 0px -20px; width:100%; height:300px; border:1px solid #555;"></div>
			</div>
			<div id="towrite" style="position:relative;float:left;margin-left:0px;">
				<div id="bar"></div>
				<div id="content" ></div>
			</div>
			
			<div id="towritelb" style="position:relative;float:left;margin-left:0px;display:none;">
				<div id="bar1"></div>
				<div id="content1" ></div>
			</div>
		</div>
		
			
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="DatePicker/WdatePicker.js"> </script> 
		<script type="text/javascript" src="js/echarts.js"></script>
		<script>
			var z = 1;   //最高板（1、显示三板及以上；0、只显示最高板）
			var bkcolor = $("body").css("backgroundColor");
			var thcolor = "";
			var tdcolor = "";
			var cbkcolor = $("#content").css("backgroundColor");		
			var day = new Date();
			var dt = "";  //当日
			var tt = "";
			var tt1 = "";
			var k = 0;			
			window.onload = function() {
				dt = day.Format("yyyy-MM-dd");							
				changeStyle();
				getSource();				
			}
			
			var ztssx = 0;
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					day = new Date();
					ztssx++;					
					if(ztssx == 5){ //定时刷新涨停数
						ztssx = 0;
						ztemp = "";	
					}		
					getSource();					
					const interval = setInterval(function(){
						if(rid != "" && y == 1){
							changeCss(rid,qid);
							clearInterval(interval);
						}					
					},100);					
					
					if(sx == 1){
						showInform(ztgp);					
					}

					if(lbt == dt){
						setTimeout(function(){lbtt()}, 100); 				
					}
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
   　　　
			$(function() {
				setInterval(function() {
					if(k == 0){		//最后交易日才刷新		
						time_range("9:00","15:15")	
					}							
				},
				60000);
			})
			
			function changeStyle() {
				var obj = document.getElementById("towriter");
				obj.style.display= "block"; 
				obj.style.left= "0px"; 				
				obj.style.width= "1450px";					
				
				var div = document.getElementById("towrites");				
				for (i = 1; i < 11; i++){
					var obj = document.createElement("div");
					obj.id = "towrite" + (11 - i);
					obj.className = "fixedBox";
					obj.style.position= "relative"; 
					obj.style.float= "left"; 
					obj.style.left= "0px"; 				
					obj.style.width= "82px";
					obj.style.height= "260px";					
					obj.style.fontSize="12px";						
					div.appendChild(obj);					
				}
				
				var obja = document.getElementById("towrite");  //个股行情窗口
				obja.style.left= "0px"; 				
				obja.style.width= "300px";							
				obja.style.fontSize="12px";		
				
				var div = document.getElementById("towritets");
				for (i = 1; i < 11; i++){
					var obj = document.createElement("div");
					obj.id = "towritet" + (11 - i);
					obj.className = "fixedBox";
					obj.style.position= "relative"; 
					obj.style.float= "left"; 
					obj.style.left= "0px"; 				
					obj.style.width= "82px";
					//obj.style.height= "60px";					
					obj.style.fontSize= "12px";
					//obj.style.border= "1px solid #696969";
					//obj.style.whiteSpace="normal";					
					div.appendChild(obj);					
				}
				
				var objb3 = document.getElementById("towritelb");  //连板行情窗口
				objb3.style.top= div.style.top; 	
				objb3.style.left= "0px"; 				
				objb3.style.width= "300px";							
				objb3.style.fontSize="12px"
			}					
			
			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};			
			
			function NumberTransform(num) { 
				var result = parseFloat(num);
				if (isNaN(result)) {                    
                   return false;  
               }  				
               if(Math.abs(result) > 100000000){
				result = result / 100000000;
				result = result.toFixed(2) + "亿";
			   }else if(Math.abs(result) > 10000){
			    result = result/10000;
				result = result.toFixed(0) + "万";
			   }
               return result;  
			};
			
			Date.prototype.Format = function (fmt) {
				var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function cDayFunc(dp) { 
				var date = dp.cal.getNewDateStr();            
				BookingRmk(date);//调用其它函数并带上参数                
			}
			
			function BookingRmk(date){         				
				tt1 = date;
				var date1 = new Date(tt1);
				var date2 = new Date(dt);
				if(date1 < date2){
					k = 1;					
				}else{
					k = 0;
					tt1 = dt;
				}				
				a = 0;  //切换日期，清零
				tz = "";
				dmz = ""; 
				getSource();				
			}
			
			var pn = -1;
			function prev(){  //前一天
				pn = -1;
				var day = new Date(tt1);	
				day.setTime(day.getTime() - 24*60*60*1000);	
				tt1 = day.Format("yyyy-MM-dd");				
				BookingRmk(tt1);
			}
			
			function next(){  //后一天 				
				pn = 1;
				var day = new Date(tt1);	
				day.setTime(day.getTime() + 24*60*60*1000);	
				tt1 = day.Format("yyyy-MM-dd");				
				BookingRmk(tt1);							
			}
			
			var y = 0;
			var bjs = "";
			var rqs = ""; //判断交易日用(缓存)
			var tz = "";  //折线图用 rq
			var dmz = "";  //折线图用 dm
			var a = 0; 
			var b = 0;
			function getSource() {
				y = 0;
				var div = document.getElementById("title");
				var qh = "<a style='position:absolute; right:180px;' href='javascript:void(0)' onclick='clearstorage()'>" + "清除缓存" + "</a>";
				var hc = "<a style='position:absolute; right:500px;' href='javascript:void(0)' onclick='qbhc()'>" + "缓存全部" + "</a>";
				var ds = "<span id='ds' style='position:absolute; left:1000px;'>" + bjs + "<span>";
				div.innerHTML = '<font color=#FF8C00; size="3">精选板块轮动<font size="1">&nbsp;&nbsp;&nbsp;&nbsp;' + qh + hc + ds + '</font></font><input style="width: 90px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';		
				var back = '<a href="javascript:prev();"  style="padding-left:10px;font-size:16px;color:#fff;">←</a>';				
				var forward = '<a href="javascript:next();"  style="font-size:16px;color:#fff;">→</a>';
				div.innerHTML += back + forward ;
				
				var url1 = "http://127.0.0.1:8880/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w21&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7";
				if(k == 0){				
					$.ajax({
						type: "get",
						url: url1,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {					
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));															
							tt1 = data.Day;							
							dt = tt1;
							day = new Date(tt1);
							rqs = tt1 + ";";  //判断交易日用										
						}
					});						
				}else{
					day = new Date(tt1);
					day.setTime(day.getTime());				
					for (i = 1; i < 100; i++){
						if(i > 1){
							day.setTime(day.getTime() + pn*24*60*60*1000);							
						}
						tt1 = day.Format("yyyy-MM-dd");						
						if(tt1 == dt){	
							k = 0;								
							getSource();
							break;
						}
						var urlt = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt1; 					
						var res1 = [];
						$.ajax({
							type: "get",
							url: urlt,
							dataType: "text",
							async : false,
							cache:false,
							timeout:3000,						
							success: function(data) {							
								if(data.indexOf("MYSQL数据库链接出错!") == -1 && data.indexOf('"list":[]') == -1 && data.indexOf('"errcode":1020') == -1){
									var arr = JSON.parse(data);
									res1 = arr.list;								
								}else{
									res1.push("");
								}														
							}
						});
						if(res1[0].length != 0){							
							break;
						}
					}
				}
				
				var url2 = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt1; 			
				var url = url1;
				if(k == "1"){
					url = url2;
				}
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {					
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));															
						for (i = 0; i < data.list.length; i++){
							res.push({"code":data.list[i][0],"name":data.list[i][1],"qd":data.list[i][2],"zf":data.list[i][3]});							
						}											
					}
				});	
				
				var div1 = document.getElementById('towrite1');																				
				div1.innerHTML = "<span style='color:#FFFF00'>" + tt1 + "</span>";					
				document.getElementById("PriceDate").value = tt1;	
				
				if(res.length != 0){
					Ctable(tt1,JSON.stringify(res),"towrite1");	
					if(dt == tt1){
						setTimeout(function(){lastday()}, 100);  //延时执行
					}	
				}
				
				y = 1;					
				thcolor = $("th").css("color");				
				tdcolor = $("td a:first").css("color");		
								
				if(k == 0){					
					if(dt == tt1 && b == 0){ //竞价后切换
						a = 0;
						b++;
					}
					a++;						
					if(a == 1){  //刷新或竞价后执行一次							
						gethis(); //交易日推算							
					}
				}else{
					gethis();						
				}
				
				//lbtt();
				setTimeout(function(){lbtt()}, 200);  //延时执行	
				//}				
			}
			
			function qbhc(){  //全部缓存
				//alert(dmz)				
				var ss = dmz.split(";");
				var n = 0;
				$("#ds").text('开始缓存……');
				setTimeout(loop, 100);
				function loop(){										
					var dm = ss[n];
					if(dm != ""){					
						$("#ds").text("正在缓存：" + dm + "（剩余：" + (ss.length - n) + "只）");						
						//hczts(dm);
						setTimeout(function(){hczts(dm)}, 200);
					}					
					n++;
					if( n < ss.length){
						setTimeout(loop, 50);
					}else{
						$("#ds").text("完成");
						setTimeout(function(){$("#ds").text("")}, 1000);
					}					
				};							
			}			
			
			function hczts(dm){  //缓存历史涨停数、连板数数据						
				var ts = tz.split(";");									
				for (i = 10; i >= 0; i--){
					tt = ts[i];					
					if(k == 0 && i == 0){  //不计算最新交易日
						tt = "";
					}
					
					if(tt != ""){					
						var p = 0;
						var zt = "";	
						var lb = "";							
						var ztshc = dm + "-zts-" + tt.replace(/-/g,""); //涨停数缓存
						
						if(localStorage.getItem(ztshc) == null){														
							var url = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=ZhiShuStockList_W8&st=60&c=ZhiShuRanking&PhoneOSNew=1&old=1&Type=20&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + dm + "&Date=" + tt;																								
							var res = [];
							$.ajax({
								type: "get",
								url: url,
								dataType: "json",
								async : false,
								cache:false,
								timeout:3000,					
								success: function(data) {	
									res = data;
								}
							});								
							var result = 0;
							for (j = 0; j < res.list.length; j++){
								var code = res.list[j][0];
								var name = res.list[j][1];								
								if(name.indexOf('ST') == -1){  //过滤ST
									if(res.list[j][28] > 0){									
										result++;  //涨停数																				
									}else{										
										zt = '["' + tt + '",' + result + "]"										
										var txt = $("#" + tt + dm).text();
										if(txt.indexOf("(") == -1){
											$("#" + tt + dm).append("(" + result + ")")
										}										
										localStorage.setItem(ztshc, zt);  //写入缓存
										break;
									}
								}							
							}							
						}	
					}					
				}					
			}			
			
			function getzts(tt, dm){  //获取涨停数
				var zt = "";								
				var ztshc = dm + "-zts-" + tt.replace(/-/g,""); //涨停数缓存											
				if(localStorage.getItem(ztshc) != null){  
					zt = localStorage.getItem(ztshc);
					zt = zt.replace(/"/g,"").split(tt + ',')[1].split(']')[0];
				}				
				return zt;
			}
			
			var ztemp = "";
			var dmx = "";  //最后交易日 板块代码
			function lastday(){	  //最后交易日 计算涨停数
				//alert(dmx);
				var aa = dmx.split(";");
				for (i = 0; i < 10; i++){
					var zt = "";
					var dm = aa[i];					
					var div = document.getElementById(dt + dm);					
					if(ztemp.indexOf(dm + '=') > -1){
						zt = ztemp.split(dm + '=')[1].split(',')[0];						
						div.innerHTML += "(" + zt + ")";
						//alert(1+"|"+zt)
					}else{	
						var url = "http://127.0.0.1:8880/w1/api/index.php?Order=1&st=60&a=ZhiShuStockList_W8&c=ZhiShuRanking&PhoneOSNew=1&old=1&Type=20&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + dm; 																					
						var result = 0;												
						var res = [];
						$.ajax({
							type: "get",
							url: url,
							dataType: "json",
							async : false,
							cache:false,
							timeout:3000,					
							success: function(data) {					
								res = data;								
							}
						});	
						
						for (j = 0; j < res.list.length; j++){																										
							var name = res.list[j][1];
							//alert(name)
							if(name.indexOf('ST') == -1){  //过滤ST
								if(res.list[j][28] > 0){							
									result++;  //涨停数							
								}else{							
									zt = result;
									ztemp += dm + '=' + zt + ',';
									break;
								}	
							}								
						}						
						div.innerHTML += "(" + zt + ")";
					}
				}
				dmx = "";
			}
			
			function UnUnicode(str) {
				return unescape(str.replace(/\\/g, "%"));
			}

			var datahis = "";
			function gethis() {			
				if(localStorage.getItem('bkldzrq') != null) {  //判断有无缓存日期
					var t = localStorage.getItem('bkldzrq'); //取缓存日期
					//alert(t)
					if(t.split(";")[0] != tt1){  //如果缓存首日不等于最后交易日，重新计算					
						for (j = 1; j < 10; j++){															
							gethisdata();							
							var div = document.getElementById("towrite" + (j + 1));	
							div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";	
							Ctable(tt,datahis,"towrite" + (j + 1));							
						}
						if(k == 0){	
							localStorage.setItem('bkldzrq', rqs);  //交易日期写入缓存
						}
					}else{  //否则取缓存数据
						for (i = 1; i < 10; i++){
							var div = document.getElementById("towrite" + (i + 1));
							tt = t.split(";")[i];							
							div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";
							datahis = localStorage.getItem('bkldz' + tt);
							Ctable(tt,datahis,"towrite" + (i + 1));								
						}				
					}				
				}else{   //首次
					for (j = 1; j < 10; j++){										
						gethisdata();						
						var div = document.getElementById("towrite" + (j + 1));	
						div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";	
						Ctable(tt,datahis,"towrite" + (j + 1));						
					}							
					localStorage.setItem('bkldzrq', rqs);  //交易日期写入缓存					
				}				
			}
									
			function gethisdata() {				
				day.setTime(day.getTime());				
				for (i = 1; i < 100; i++){	//节假日																										
					day.setTime(day.getTime() - 24*60*60*1000);
					tt = day.Format("yyyy-MM-dd");
					//alert(tt);
					var url = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt; 										
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "text",
						async : false,
						cache:false,
						timeout:3000,						
						success: function(data) {							
							if(data.indexOf("MYSQL数据库链接出错!") == -1 && data.indexOf('"list":[]') == -1 && data.indexOf('"errcode":1020') == -1){
								var arr = JSON.parse(data);
								for (i = 0; i < arr.list.length; i++){
									res.push({"code":arr.list[i][0],"name":arr.list[i][1],"qd":arr.list[i][2],"zf":keepTwoDecimal(arr.list[i][3])});							
								}								
							}else{
								res.push("");
							}														
						}
					});
					if(res[0].length != 0){	
						rqs += tt + ";"
						if(localStorage.getItem('bkldz' + tt) != null) {   //判断有无缓存数据														
							datahis = localStorage.getItem('bkldz' + tt);    //取缓存数据							
						}else{														
							datahis = JSON.stringify(res);
							localStorage.setItem('bkldz' + tt, datahis);  //历史单日数据写入缓存
						}				
						break;
					}
					
				}				
			}
			
			function getdczts(tt) {	//东财涨停数据
				var data = "";
				if(localStorage.getItem('dczts' + tt) != null) {   //判断有无缓存数据														
					data = localStorage.getItem('dczts' + tt);    //取缓存数据							
				}else{	
					url = "http://push2ex.eastmoney.com/getTopicZTPool?cb=callbackdata1207668&ut=7eea3edcaed734bea9cbfc24409ed989&dpt=wz.ztzt&Pageindex=0&pagesize=1000&sort=lbc%3Adesc&date=" + tt.replace(/-/g,""); 										
					$.ajax({
						type: "get",
						url: url,
						dataType: "text",
						async : false,
						cache:false,
						timeout:3000,						
						success: function(data) {	
						//document.write(data);
							if(data.indexOf('"data":null') == -1){
								data = data.replace(/ /g,"").match(/\"pool\":(\S*)\}\}\);/)[1];
								//document.write(data);
								data = data.replace(/(\{\").*?(?=\})/g,function(word){ 				
									str = word.match(/\{(\S*)/)[1];	
									var lb = str.split(',')[9];					
									lb = lb.match(/"lbc":(\S*)/)[1];					
									return "{" + str.split(',')[0] + "," + str.split(',')[2] + "," + str.split(',')[9];							
								});
								data = data.replace(/}},{/g,"},{").replace(/}}]/g,"}]").replace(/}},/g,"");		
								//document.write(data);
								if(tt != dt){ //最新交易日不写入
									localStorage.setItem('dczts' + tt, data);  //历史单日数据写入缓存
								}
							}else{
								data = "";
							}
						}
					});					
				}
				return data;
			}
			
			function getkplzts(tt) {	//kpl涨停数据								
				var datas = "";
				if(localStorage.getItem('kplzts' + tt) != null) {   //判断有无缓存数据														
					datas = localStorage.getItem('kplzts' + tt);    //取缓存数据							
				}else{	
					var res = [];
					for (i = 0; i < 5; i++){
						var p = 5 - i;								
						var url1 = "http://127.0.0.1:8880/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=60&apiv=w21&Type=4&c=HomeDingPan&PidType=" + p;
						var url2 = "http://127.0.0.1:8881/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&PidType=" + p + "&Day=" + tt;				
						var url = url1;
						if(tt != dt){					
							url = url2;
						}
						
						var arr = [];
						$.ajax({
							type: "get",
							url: url,
							dataType: "json",
							async : false,
							cache:false,
							timeout:3000,					
							success: function(data) {
								//alert(JSON.stringify(data))						
								//document.write(JSON.stringify(data));	
								arr = [];
								if(data.info[0].length > 0){					
									for (j = 0; j < data.info[0].length; j++){
										var lb = "";
										if(p == 5){
											var lbs = data.info[0][j][18];							
											lb = lbs;
											if(lbs.indexOf("天") > -1){
												lb = 5;
											}
										}else{
											lb = p;
										}
										arr.push({"code":data.info[0][j][0],"name":data.info[0][j][1],"lbc":lb});							
									}	
								}
							}
						});	
						if(arr.length > 0){
							res = res.concat(arr);
						}
					}					
					datas = JSON.stringify(res).replace(/连板/g,"");
					if(tt != dt){ //最新交易日不写入
						localStorage.setItem('kplzts' + tt, datas);  //历史单日数据写入缓存
					}
				}				
				return datas;				
			}
						
						
			function Ctable(tt,ss,id){
				if(tz.indexOf(tt) == -1){
					tz += tt + ";";
				}
				var json = JSON.parse(ss);				
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
				
				var m = 0;
				var n = 0;
				var b = 0;
				var h = 1;
				var gl = "强度";  //高亮				
				for(var key in json[0]){  //表头
					key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('qd','强度');
					//key = key.replace('ZJJE','主力净额').replace('gang','主力').replace('plate','板块').replace('index','异动次数');					
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);
					if(gl == key.replace("%","")){
							n = m;
							th.style.color = "#FF6633";	
						}					
					m++;
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				var zts = "";				
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;
					var dm = "";
					var mc = "";
					for(var key in json[i]){ //行元素遍历						
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							if(dt != tt){
								zts = " (" + getzts(tt, dm) + ")";
							}
							tr.id = dm + id;
						}else if(p == 2){  //名称列
							mc = rc;								
						}	
						if(p == 2){
							if(zts != " ()"){
								td.innerHTML = "<a href='javascript:void(0)' style='float:left;' id='" + tt + dm + "' onclick='showInform(\"" + tt + "#" + dm + "#" + mc + "\");changeCss(\"" + dm + id + "\",\"" + id + "\")'>" + rc + zts + "</a>";						
							}else{
								td.innerHTML = "<a href='javascript:void(0)' style='float:left;' id='" + tt + dm + "' onclick='showInform(\"" + tt + "#" + dm + "#" + mc + "\");changeCss(\"" + dm + id + "\",\"" + id + "\")'>" + rc + "</a>";						
							}
						}else{
							td.innerHTML = "<a href='javascript:void(0)' style='float:left;' onclick='showInform(\"" + tt + "#" + dm + "#" + mc + "\");changeCss(\"" + dm + id + "\",\"" + id + "\")'>" + rc + "</a>";
						}
						
						if(p == n + 1){							
							td.getElementsByTagName("a")[0].style.color = "#FF6633";
						}																				
						tr.appendChild(td);							
						p++;
					}														
					if(mc.indexOf("ST") == -1 && h < 11){		//过滤ST	限制10行															
						if(dmz.indexOf(dm) == -1){
							dmz += dm + ";";
						}
						if(tt == dt){
							dmx += dm + ";";
						}						
						tbody.appendChild(tr);
						h++;
					}	
				}
				var div = document.getElementById(id);					
				div.appendChild(table);
				table.id = id;
				changeTable(table,'0#2#3');		//隐藏某列	
				hover();				
			}
			
			//隐藏某列				
            function changeTable(table,ss) {	
				var trs = table.rows;
				ss = ss + '#';
				var aa = ss.split('#');
				for (var j = 0; j < aa.length; j++) {
					if(aa[j] != ""){
						for (var i = 0, len = trs.length; i < len; i++) {					
							var p = aa[j];
							var cell = trs[i].cells[p]; 
							cell.style.display = 'none';
						}
					}
				}					
			}
			
			//方式1		
			var pid = "";
			function changeCss1(obj,hid,id){						
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
				
				//5组选中行id集合
				if(pid.indexOf(id) > -1){				
					var aa = "";				
					var ss = pid.split(";");
					for(i = 0; i < ss.length-1; i++){
						if(ss[i].indexOf(id) > -1){						
							aa += hid + ";";
						}else{
							aa += ss[i] + ";";
						}				
					}
					pid = aa;
				}else{
					pid += hid + ";";
				}
				
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			//方式2：相同行高亮
			var qid = "";
			var rid = "";
			function changeCss(hid,id){				
				qid = id;
				rid = hid;
				//alert(rid + "|" + qid)
				var tlist = document.getElementById("towriter").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
								
				pid = "";				
				var dm = hid.split("towrite")[0];				
				for(var i = 0; i < tlist.length; i++){
					var a = tlist[i].id;
					if(a.split("towrite")[0] == dm){
						//alert(a)
						tlist[i].style.backgroundColor = "#483D8B";
						pid += a + ";";
					}					
				}				
			}
			
			function changeCsss(hid,id){				
				qid = id;
				rid = hid;
				//alert(rid + "|" + qid)
				var tlist = document.getElementById("towriter").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
								
				pid = "";				
				var dm = hid.split("towrite")[0];				
				for(var i = 0; i < tlist.length; i++){
					var a = tlist[i].id;
					if(a.split("towrite")[0] == dm){
						//alert(a)
						tlist[i].style.backgroundColor = "#DDA0DD";
						pid += a + ";";
					}					
				}					
			}
			
			function hover(){  //鼠标经过			
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头							
							if(pid.indexOf(this.id) == -1){  //过滤选中行
								this.style.background = bkcolor;
							}else{
								this.style.background = "#483D8B";
							}
						}						
					}					
				}
			}
			
			var rqb = "";
			var bkb = "";			
			var ztgp = "";
			var sx = 0;
			function showInform(ss){
				//alert(ss)
				var div1 = document.getElementById('towrite');
				div1.style.display = "block";
				var div2 = document.getElementById('towritelb');
				div2.style.display = "none";
				ztgp = ss;
				
				var dms = ss.split('#');
				var rq = dms[0];				
				if(rq == ""){
					rq = tt1;
				}
				var dm = dms[1];
				var bk = dms[2];
				
				
				var div = document.getElementById('bar');											
				var bfyy = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				
				var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>'
				var forward = '<a href="javascript:forward(' + dm + ');"  style="color:#fff">→</a>'
				div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rq + "&nbsp;&nbsp;" + bfyy + '日期：' + back + forward + "</b>";
				
				update(rq,dm);	
				rqb = rq;
				bkb = bk;
								
				if(rq == dt){
					sx = 1;
				}else{
					sx = 0;
				}
			}
			
			function forward(dm) {				
				var rq = rqb;			
				//alert(rq)
				var ts = tz.split(";");					
				for (i = 10; i >= 0; i--){					
					if(rq == ts[i] && i > 0){						
						rq = ts[i-1];
						break;
					}
				}
				if(i > 0){
					rqb = rq;
					var div = document.getElementById('bar');											
					var bfyy = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				
					var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>'
					var forward = '<a href="javascript:forward(' + dm + ');"  style="color:#fff">→</a>'
					div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rq + "&nbsp;&nbsp;" + bfyy + '日期：' + back + forward + "</b>";					
					update(rq,dm);
				}
			}
			
			function back(dm) {				
				var rq = rqb;							
				var ts = tz.split(";");								
				for (i = 0; i < ts.length; i++){				
					if(rq == ts[i] && i < ts.length-2){						
						rq = ts[i+1];
						break;
					}
				}				
				if(i < ts.length-2){
					rqb = rq;
					var div = document.getElementById('bar');											
					var bfyy = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='updateb(" + dm + ")'>【爆发原因】</a>";				
					var back = '<a href="javascript:back(' + dm + ');"  style="color:#fff">←</a>'
					var forward = '<a href="javascript:forward(' + dm + ');"  style="color:#fff">→</a>'
					div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rq + "&nbsp;&nbsp;" + bfyy + '日期：' + back + forward + "</b>";										
					update(rq,dm);
				}
			}
			
			var Order = 1;
			var old = 1; 
			var dmb = "";
			function update(tt,dm) {				
				dmb = dm;	
				var url = "";
				if(k == 0 && tt == tt1){				
					url = "http://127.0.0.1:8880/w1/api/index.php?Order=" + Order + "&st=60&a=ZhiShuStockList_W8&c=ZhiShuRanking&PhoneOSNew=1&old=" + old + "&apiv=w21&Type=6&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + dm; 												
				}else{
					url = "http://127.0.0.1:8881/w1/api/index.php?st=60&Index=0&old=" + old + "&Order=" + Order + "&a=ZhiShuStockList_W8&apiv=w26&Type=6&c=ZhiShuRanking&PhoneOSNew=1&DeviceID=6575961a-b25b-3831-aa2b-4a373b51b256&VerSion=5.12.0.0&PlateID=" + dm + "&Date=" + tt;												
				}
								
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));																
						for (i = 0; i < data.list.length; i++){
							res.push({"code":data.list[i][0],"name":data.list[i][1],"zf":data.list[i][6],"lz":data.list[i][24],"lb":data.list[i][23],"zt":data.list[i][39]});							
						}											
					}
				});			

				//var json = JSON.parse(data);
				var json = res;	
						
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
				
				var m = 0;
				var v = 0;
				var b = 0;
				var gl = "领涨";  //高亮
				if(rs == 2){
					gl = "涨幅";
				}
				for(var key in json[0]){  //表头													
					key = key.replace('code','代码').replace('name','名称').replace('zf','涨幅%').replace('zl','主力').replace('lz','领涨');
					key = key.replace('lb','连板').replace('zt','主题').replace('zs','涨速%');
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);					
					if(key == "领涨" || key == "主力" || key == "连板" || key == "主题"){
						th.id = "BJ";
						th.style.color = "#FFA500";	
					}	
					if(gl == key.replace("%","")){
						v = m;
						th.style.color = "#FF6633";	
						if(rs == 2 && Order == 0){
							th.style.color = "#ADFF2F";	
						}
					}
					m++;
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;	
					var dm = "";
					var mc = "";					
					for(var key in json[i]){ //行元素遍历					
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							tr.id = dm;
						}					
						td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='changeTCss(this,\"" + dm + "\",\"gg\")'>" + rc + "</a>";
							
						if(p > 3){	
							td.getElementsByTagName("a")[0].id = "BJ" + p;
							td.getElementsByTagName("a")[0].style.color = "#FFA500";															
						}
						if(p == v + 1){							
							td.getElementsByTagName("a")[0].style.color = "#FF6633";
							if(rs == 2 && Order == 0){
								td.getElementsByTagName("a")[0].style.color = "#ADFF2F";
							}
						}						
						tr.appendChild(td);
						p++;
					}						
					tbody.appendChild(tr);
				}	
				//var div = document.getElementById("inform");
				var div = document.getElementById("content");
				div.style.whiteSpace = "nowrap"; 
				div.style.fontSize="12px";
				div.scrollTop = 0; //回到顶部	
				div.innerHTML = "";					
				div.appendChild(table);
				table.id = "gg";					
				
				
				var table=div.getElementsByTagName("table")[0];
				makeSortable(table);			
				ihover();
				//changeTable(table,'0#4#6');
			}
			
			var trid = "";
			function changeTCss(obj,hid,id){						
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = cbkcolor; 					
				}
				trid = hid;
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			function ihover(){  //鼠标经过
				var rows = document.getElementById("gg").getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头
							if(this.id != trid){  //过滤选中行
								this.style.background = cbkcolor;
							}else{
								this.style.background = "#483D8B";
							}
						}						
					}					
				}
			}	
			
			var pt = 0;
			var rs = 0
			function makeSortable(table) {
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){
							//alert(n);	
							
							if(n == 2){
								rs = n;
								Order = (pt%2 == 0) ? "1" : "0";								
								old = 0; 
								update(rqb,dmb);
								pt++;
							}
							
							if(old == 0 && n != 2){
								rs = 0;
								Order = 1;
								old = 1; 								
								update(rqb,dmb);
							}
							
							if(n != 2){
								showCol(n);		//高亮
							}	
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("主力") != -1|| headtxt.indexOf("主题") != -1){
									val1 = val1;
									val2 = val2;
								}else if(headtxt.indexOf("连板") != -1){								
									val1 = val1.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val1.indexOf("天")>-1){
										val1 = val1.split("天")[0];
									}else if(val1.indexOf("昨")>-1){
										val1 = 0;
									}else if(val1 == ""){
										val1 = -2;
									}										
									val1 = parseFloat(val1);
								
									val2 = val2.replace("昨日首板","-1").replace("首板","1").replace("连板","");
									if(val2.indexOf("天")>-1){
										val2 = val2.split("天")[0];
									}else if(val2.indexOf("昨")>-1){
										val2 = 0;
									}else if(val2 == ""){
										val2 = -2;
									}									
									val2 = parseFloat(val2);
								}else if(headtxt.indexOf("领涨") != -1){
									val1 = val1.replace("龙十","龙一十").replace("破板","1000");
									val2 = val2.replace("龙十","龙一十").replace("破板","1000");
									if(val1 == ''){
										val1 = '1001';
									}
									if(val2 == ''){
										val2 = '1001';
									}
									if(val1.indexOf("龙") != -1){
										val1 = ChineseToNumber(val1.replace("龙",""));										
									}										
									if(val2.indexOf("龙") != -1){
										val2 = ChineseToNumber(val2.replace("龙",""));
										
									}
									//val2 = parseFloat(val2);									
								}else{
									if(val1 == "-"){
										val1 = " ";
									}
									if(val2 == "-"){
										val2 = " ";
									}
									val1 = val1.replace(" ","0").replace("无","1000").replace("NaN","0");
									val2 = val2.replace(" ","0").replace("无","1000").replace("NaN","0");
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
								
							});
							if(flag){
								rows.reverse();								
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;							
						}
					}(i));
				}
			}
			
			function showCol(iCol){			
				var oTable = document.getElementById("content").getElementsByTagName('table')[0];
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = "#E5E5E5";
						
						if(oTable.rows[i].cells[j].id == "BJ"){
							oTable.rows[i].cells[j].style.color = "#FFA500"; 
						}						
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}

				otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = "#E5E5E5";
					if(otagsA[i].id.indexOf("BJ") > -1){
						otagsA[i].style.color = "#FFA500";								
					}
					if(otagsA[i].id.replace("BJ","") == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}								
			}
			
			var chnNumChar = {零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9};

			var chnNameValue = {
			  十:{value:10, secUnit:false},
			  百:{value:100, secUnit:false},
			  千:{value:1000, secUnit:false},
			  万:{value:10000, secUnit:true},
			  亿:{value:100000000, secUnit:true}
			}

			function ChineseToNumber(chnStr){
			  var rtn = 0;
			  var section = 0;
			  var number = 0;
			  var secUnit = false;
			  var str = chnStr.split('');

			  for(var i = 0; i < str.length; i++){
				var num = chnNumChar[str[i]];
				if(typeof num !== 'undefined'){
				  number = num;
				  if(i === str.length - 1){
					section += number;
				  }
				}else{
				  var unit = chnNameValue[str[i]].value;
				  secUnit = chnNameValue[str[i]].secUnit;
				  if(secUnit){
					section = (section + number) * unit;
					rtn += section;
					section = 0;
				  }else{
					section += (number * unit);
				  }
				  number = 0;
				}
			  }
			  return rtn + section;
			}
			
			function clearstorage(){
				//var t = localStorage.getItem('bkldzrq'); //取缓存日期
				//alert(t)
				if(localStorage.getItem('bkldzrq') != null){						
					localStorage.removeItem('bkldzrq'); //清除缓存localStorage
				}
				
				var n = 1;
				while (n > 0)
				{	
					var p = 1;				
					var q = p;
					for (var i = 0; i < localStorage.length; i++) { 
						var key = localStorage.key(i);		 				
						if(key.indexOf('lbtt') > -1 || key.indexOf('bkldz') > -1 || key.indexOf('-zts-') > -1 || key.indexOf('-lbs-') > -1 || key.indexOf('dczts') > -1  || key.indexOf('kplzts') > -1){							
							localStorage.removeItem(key);	
							p++;
						}	
					}
					n = p - q;					
				}
				alert('清除完成');
			}
			
			function updateb(ss) {
				//alert(ss)	
				var dm = ss; 			 				
				var url4 = "http://127.0.0.1:8880/w1/api/index.php?a=GetBaseFaceListZDEvnArtNew&apiv=w26&c=ZhiShuL2Data&StockID=" + dm;				
				var url5 = "http://127.0.0.1:8881/w1/api/index.php?a=GetDayBaseFaceListZDEvnArt&st=10&c=ZhiShuKLine&apiv=w26&StockID=" + dm; 								
				
				var res4 = [];
				$.ajax({
					type: "get",
					url: url4,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));							
						res4 = data;								
					}
				});				

				var res5 = [];
				$.ajax({
					type: "get",
					url: url5,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));							
						res5 = data;									
					}
				});		
				//document.write(data);						
				var div1 = document.getElementById('bar');												
				var fh = "<a style='padding-left:10px;font-size:12px;color:#F0FFFF;' href='javascript:void(0)' onclick='showInform(\"" + ztgp + "\")'>【返回】</a>";			
				div1.innerHTML = "<b style='color:#FFFF00;margin:5px;'>" + rqb + "&nbsp;&nbsp;" + bkb + fh + "</b>";
																					
				var div = document.getElementById("content");						
				var rq = res4.Date;
				if(rq != ""){					
					var data = JSON.stringify(res4);					
					var day = new Date();
					gt = day.getTime();			
					mymonth = day.getMonth()+1;
					myday = day.getDate();
					if(mymonth >= 10){mymonth = mymonth;}else{mymonth = "0" + mymonth;}
					if(myday >= 10){myday = myday;}else{myday = "0" + myday;}
					tt = day.getFullYear() + "-" + mymonth + "-" + myday;													
					if(rq == tt){
						var transform_aa = [           
						{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
						];
						
						var transform_bb= 
						{"tag":"p", children:[
						{"tag":"li", children:[							
						{"tag": "p style=color:#FFFF00;font-size:14px;", "html":"${Date}：${BoomReason}"},
						{"tag": "p style=margin-top:-5px;color:#FFA500;font-size:14px;", "html":"${Title}"}, 								
						]}]}; 
						
						var html = json2html.transform(data, transform_aa);																						
						div.innerHTML = html;
					}
				}
				
				if(res5.List.length > 0){
					var data1 = JSON.stringify(res5);
					var transform_aa = [           
					{"tag":"ul", children:function(){return(json2html.transform(this.List, transform_bb));}}
					];
					
					var transform_bb= 
					{"tag":"p", children:[
					{"tag":"li", children:[							
					{"tag": "p style=color:#E1FFFF;font-size:14px;", "html":"${Date}：${BoomReason}"},
					{"tag": "p style=margin-top:-5px;color:#FFA500;font-size:14px;", "html":"${Title}"}, 								
					]}]}; 
					
					var html = json2html.transform(data1, transform_aa);					
					div.innerHTML = html;
				}else if(data1.indexOf('\"List\":[]') > -1 && data.indexOf('"Date":""') > -1){						
					div.innerHTML = "暂无数据";	
				}
				div.style.whiteSpace = "normal";  //折行
				div.style.fontSize="14px";						
			}
			
			var datahq = "";
			var lbt = "";
			function lbtt(){  //连板天梯				
				var lbs = [];
				var ts = tz.split(";");	
				lbt = ts[0];				
				for (i = 9; i >= 0; i--){
					//alert(ts[i])
					datahq = "";					
					if(i == 0 && dt == ts[0]){   //当日为最新交易日
						for (j = 0; j < 5; j++){
							getdata(5 - j, dt);					
						}
						datahq = datahq.replace(/\}\]\[\{/g,"},{");
					}else{
						if(localStorage.getItem('lbtt' + ts[i]) != null) {   //判断有无缓存数据														
							datahq = localStorage.getItem('lbtt' + ts[i]);    //取缓存数据	
							//alert(datahq)
						}else{
							for (j = 0; j < 5; j++){
								getdata(5 - j, ts[i]);;					
							}							
							datahq = datahq.replace(/\}\]\[\{/g,"},{");							
							localStorage.setItem('lbtt' + ts[i], datahq);  //历史单日数据写入缓存							
						}
					}
					//alert(ts[i]+ datahq)
					//alert(datahq)
					var data = [];
					var arr = [];
					var lbd = 0;
					var lbd2 = 0;
					if(datahq != ""){
						var hqarr = JSON.parse(datahq);						
						for (i1 = 0; i1 < hqarr.length; i1++){	
							var code = hqarr[i1].code;
							var lb = hqarr[i1].lb;							
							lb = lb.replace("连板","").replace("板","");
							
							if(arr.indexOf(lb) == -1){
								arr.push(lb);
							}
							
							
							if(i1 == 0){
								lbd = parseInt(lb);
							}
							if(parseInt(lb) > parseInt(lbd)){  //实际最高板
								lbd = lb;								
							}
							
							if(parseInt(lb) >= parseInt(lbd) || (z == 1 ? parseInt(lb) > 2 : 0)){
								//data += ss[i1] + "},{";	
								data.push(hqarr[i1]);
							}else{								
								break;
							}							
						}
					}
					arr.push("1");
					arr.sort(function(a,b){ //排序
						return b-a;
					})
					
					lbd = arr[0];
					lbd2 = arr[1];					
					
					var result = data;							
					function up(a,b){
						var	aa = a.lb;
						aa = aa.replace("连板","").replace("板","");
						
						var	bb = b.lb;
						bb = bb.replace("连板","").replace("板","");
						return bb-aa
					}					
					result.sort(up);
					var mc = "";
					var cc = "";
					var mc2 = "";
					var cc2 = "";
					var n = 1;
					for (i2 = 0; i2 < result.length; i2++){	
						var aa = result[i2]["lb"];
						var bb = result[i2]["name"];
												
						if(i2 == 0){
							cc = aa;
							mc = bb;						
						}
						
						if(aa == cc && mc.indexOf(bb) == -1){							
							mc += "\r\n" + bb;						
						}
						
						if(cc2 == "" && aa != cc){
							cc2 = aa;
							mc2 = bb;
						}
						
						if(aa == cc2 && mc2.indexOf(bb) == -1){
							if( n < 4){
								mc2 += "\r\n" + bb;
							}else if( mc2.indexOf("……") == -1){
								mc2 += "\r\n……";
							}
							n++;
						}
					}
					
					lbs.push({"rq":ts[i],"zg1":lbd,"zg2":lbd2,"mc":mc,"mc2":mc2});
					data = JSON.stringify(result);	

					<!-- if(i == 0){ -->
						<!-- document.write(data); -->
					<!-- } -->
					
					data = '{"data":' + data + "}";
					//data = data.replace("},{]}","}]}");
					
					var transform_aa = [           
					{"tag":"p", children:function(){return(json2html.transform(this.data, transform_bb));}}
					];
					
					var transform_bb= 
					{"tag":"p", children:[												
					{"tag": "p", "html":"<a id='${code}' style='margin-left:-10px;color:#FFFACD;' href='http://www.treeid/code_${code}' onclick='changeCssa(this);showInform1(\"" + ts[i] + "\",\"${code}\",\"${name}\");'>${name}(${lb})</a>"}, 
					]}; 
										
					var html = json2html.transform(data, transform_aa);		
				
					var div = document.getElementById("towritet" + (i+1));	
					div.innerHTML = html.replace(/连/g,'');	
					//Ctable1(data, "towritet" + (i+1));
				}
				console.log("lbs",lbs);
				//alert(JSON.stringify(lbs));				
				//document.write(JSON.stringify(lbs));
				GetChart(lbs);
				//GetChart(lbs);
				//setTimeout(function(){GetChart(lbs)}, 200); 
			}
			
			function changeCssa(obj){				
				var alist = document.getElementById("towritets").getElementsByTagName("a");				
				for(var i = 0; i < alist.length; i++){									
					alist[i].style.color = "#FFFACD"; //给所有a标签赋原色
					if(alist[i].id == obj.id){
						alist[i].style.color = "#FF7F50";
					}
				}				
				obj.style.color = "#00FFFF"; //令当前标签高亮
			}
			
			function getdata(i, rq) {			
				var url1 = "http://127.0.0.1:8880/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=60&apiv=w21&Type=4&c=HomeDingPan&PidType=" + i; 								
				var url2 = "http://127.0.0.1:8881/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&PidType=" + i + "&Day=" + rq;
				
				var url = url1;
				if(k == "1" || dt != rq){
					url = url2;
				}									
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));								
						if(data.info[0].length > 0){					
							for (var j = 0; j < data.info[0].length; j++){								
								var lbs = data.info[0][j][15] + "连板";
								lbs = lbs.replace("1连板","1板");
								res.push({"code":data.info[0][j][0],"name":data.info[0][j][1],"fde":NumberTransform(data.info[0][j][6]),"lb":lbs,"ztyy":data.info[0][j][5]});							
							}							
						}
					}
				});					
				if(res.length > 0){
					datahq += JSON.stringify(res);					
				}else{
					datahq += "";
				}										
			}					
			
			function showInform1(rq, dm, name){
				//alert(rq)
				var div1 = document.getElementById('towrite');
				div1.style.display = "none";
				var div2 = document.getElementById('towritelb');
				div2.style.display = "block";
				$("#ds").text(dm + " " + name);	
				
				var div = document.getElementById('bar1');
				div.innerHTML = "<b style='color:#FFFF00;margin:5px;'>连板&nbsp;&nbsp;&nbsp;" + rq + "</b>";
				
				var data = "";
				datahq = "";
				if(dt == rq){   //当日为最新交易日
					for (j = 0; j < 5; j++){
						getdata(5 - j, dt);					
					}
					data = datahq.replace(/\}\]\[\{/g,"},{");
				}else{
					if(localStorage.getItem('lbtt' + rq) != null) {   //判断有无缓存数据														
						data = localStorage.getItem('lbtt' + rq);    //取缓存数据	
						//alert(datahq)
					}
				}
				Ctable1(data);
								
				var tlist = document.getElementById("towritelb").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 
					if(tlist[i].id == dm){
						tlist[i].style.backgroundColor = "#483D8B";
					}
				}				
			}
			
			function Ctable1(ss){
			//alert(ss)
				var json = JSON.parse(ss);				
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
																				
				for(var key in json[0]){  //表头
					key = key.replace('code','代码').replace('name','名称').replace('fde','封单额').replace('lb','连板').replace('ztyy','涨停原因');					
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);	
					//th.style.color = "#E1FFFF";
					if(key == "连板"){												
						th.style.color = "#FFA500";							
					}
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;
					var dm = "";
					var mc = "";
					for(var key in json[i]){ //行元素遍历						
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							tr.id = dm;
						}else if(p == 2){  //名称列
							mc = rc;								
						}	
						td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' style='float:left;'  onclick='changeCss1(this,\"" + dm + "\")'>" + rc + "</a>";																										
						//td.getElementsByTagName("a")[0].style.color = "#E1FFFF";
						if(p == 4){														
							td.getElementsByTagName("a")[0].style.color = "#FFA500";
						}					
						tr.appendChild(td);							
						p++;
					}																																	
					tbody.appendChild(tr);						
						
				}
				var div = document.getElementById("content1");
				div.innerHTML = "";		
				div.appendChild(table);
				//table.id = id;
				//changeTable(table,'0#2');
				makeSortable1(table)
				hover1();				
			}
			
			var pid1 = "";
			function changeCss1(obj, dm){				
				var tlist = document.getElementById("towritelb").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 
					if(tlist[i].id == dm){
						tlist[i].style.backgroundColor = "#483D8B";
					}
				}									
				pid1 = dm;	
				
				var alist = document.getElementById("towritets").getElementsByTagName("a");				
				for(var i = 0; i < alist.length; i++){									
					alist[i].style.color = "#FFFACD"; //给所有a标签赋原色
					if(alist[i].id == dm){
						alist[i].style.color = "#FF7F50";
					}
				}								
			}
			
			function makeSortable1(table) {			
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){
													
							showCol1(table,n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("连板") != -1 || headtxt.indexOf("涨停原因") != -1){
									val1 = val1;
									val2 = val2;
								}else{											
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
							});
							if(flag){
								rows.reverse();
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
						}
					}(i));
				}
			}
			
			function showCol1(table,iCol){			
				var oTable = table;
				var id = oTable.id;
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = thcolor;
						oTable.rows[i].cells[3].style.color = "#FFA500";					
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}
				
				var otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = tdcolor;
					if(otagsA[i].id == 4){
						otagsA[i].style.color = "#FFA500";
					}						
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}				
			}
			
			function hover1(){  //鼠标经过
				var div = document.getElementById("towritets");			
				var rows = div.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头							
							if(pid1.indexOf(this.id) == -1){  //过滤选中行
								this.style.background = bkcolor;
							}else{
								this.style.background="#483D8B";
							}
						}						
					}					
				}
			}
			
			function getParamValues(name, arr) {			
				var ret = []
				for (var i = 0, len = arr.length; i < len; i++) {
					ret.push(arr[i][name])
				}
				return ret
			}
			
		</script>
		<script>
			function GetChart(arr) {
				document.getElementById("charts3").removeAttribute("_echarts_instance_");  //先清空图表(series文字错位)
				var myChart = echarts.init(document.getElementById('charts3'));
				var n1 = 0;	
				var n2 = 0;
				var option = {
					title:{
						left:'left',						
						//text: '实时资金流向',
						textStyle:{ //设置主标题风格
							color:'#FFFF00',//设置主标题字体颜色
							fontStyle:'normal',//主标题文字风格
							fontSize: 14
						}
					},				
					grid: { // 边距
					  left: '1%',
					  right: '1%',
					  bottom: '10%',
					  top: '10%',					  
					},
					legend: {   // 图例
						show: true,
						orient: 'horizontal',  //布局 默认横向布局'horizontal'，纵向布局’vertical’
						//x:'left',
						//y:'top',						
						type: "plain", // 图例的类型 'plain':普通图例  'scroll':可滚动翻页的图例
						zlevel: 1, // 所有图形的 zlevel 值。
						icon: "circle",  //控制形状  类型包括 circle 圆形，triangle 三角形，diamond 四边形，arrow 变异三角形，none 无
						top: "0%", // bottom:"20%" // 组件离容器的距离
						left: "1%", //left:"10%"  // // 组件离容器的距离         
						padding: 5, // 图例内边距	
						align: "auto", // 图例标记和文本的对齐
						itemGap: 30, // 图例每项之间的间隔。
						itemWidth: 15,     // 图例标记的图形宽度
						itemHeight: 12,      // 图例标记的图形高度// 使用字符串模板，模板变量为图例名称 {name}	
						<!-- formatter: function (item) {							 -->
							<!-- return item.substr(0,2) + jlr.split("," + item)[1].split(",")[0] -->
						<!-- }, -->
						textStyle: {
							color: "#fff", // 文字的颜色。								
						}
					},					
					xAxis: [		//x轴设置		  
						{
							type: 'category',								
							data: getParamValues('rq', arr),							
							axisLine:{  //x轴坐标线设置
								lineStyle:{
									type: 'dotted',   //坐标轴虚线（'solid'，实线类型；'dashed'，虚线类型；'dotted',点状类型）
									color:"#D3D3D3",  //x轴坐标线颜色
									//width: 2   // 坐标轴线宽
								}
							},
							axisTick: {   //x轴刻度
								show:false, 
							},
							axisLabel:{	 //x轴标签设置	
								interval: 0,
								<!-- formatter: function (value, index) {									 -->
									 <!-- if(value=="09:31" || value=="10:30" || value=="11:30" || value=="14:00" || value=="15:00"){ -->
										<!-- return value -->
									 <!-- } -->
								 <!-- }, -->
								textStyle:{  //x轴文字
									color:"#FFF"
								}
							},
							axisPointer: {
								type: 'shadow',								
							}
						}
					],

					yAxis: [  //y轴
						{
							type: 'value',
							<!-- min: function(value) {//取最小值向下取整为最小刻度									 -->
								<!-- return Math.floor(value.min) -->
							<!-- }, -->
							max: function(value) {//取最大值向上取整为最大刻度								
								return  Math.ceil(value.max + 1) 								
							},
							interval: function (value) { // 刻度间隔
								if(value.max < 0){
									return  Math.ceil(value.min) 
								}else{
									return  Math.ceil(value.max)
								}									
							},								
							splitLine:{ //y轴网格线									
								show:false,
								lineStyle: { 								
									color: '#D3D3D3', 
									width: 1,    
									type: 'dotted', //（'solid'，实线类型；'dashed'，虚线类型；'dotted',点状类型）
								} 
							},
							axisLine: { //y轴坐标线设置
								show: true, 									
								lineStyle: { 									
									color: '#D3D3D3', //y轴颜色
									//width: 2,    // 坐标轴线宽
									type: 'dotted',     // 坐标轴线线的类型（'solid'，实线类型；'dashed'，虚线类型；'dotted',点状类型）
								} 
							},
							axisTick: {   //y轴刻度
								show:false, 
							},
							axisLabel: {  //y轴标签设置
								show: true,
								color: '#fff',									
								formatter: function (value){
									return value
								}
							}
						},
					],					
					series: [						
						{							
							name: '最高板',
							data: getParamValues('zg1', arr),							
							type: 'line',								
							symbol: 'circle',//拐点样式‘circle’, ‘rect’, ‘roundRect’, ‘triangle’, ‘diamond’, ‘pin’, ‘arrow’ 
							symbolSize: 1,//拐点大小														
							label: {
								normal: {
									show: true,
									<!-- position: 'top', -->
									offset:[-20,0],
									formatter:function(param){										
										console.log(n1);
										n1++;
										var name = arr[n1 - 1]["mc"];
										return param.value  + "连板：\r\n" + name;																			
									},
									textStyle:{//拐点上标字体大小颜色
										align:'left',
										lineHeight:15,										
										color:'#FFA07A',
										fontSize:'12',
									}	
								}
							},
							itemStyle: {
							  normal: {
								lineStyle: {
								type:'solid', //'dotted'点型虚线 'solid'实线 'dashed'线性虚线
								  width: 1,//折线宽度
								  color: "#FF0000"//折线颜色
								},
								
								color: '#FF0000',//拐点颜色
								borderColor: '#fff',//拐点边框颜色
								//borderWidth: 1,//拐点边框大小
							  },
							  emphasis: {  //hover设置，不设置可跟随前面定义
								//color: '#FF0000',//hover拐点颜色定义								
								//borderColor: '#fff',//hover拐点边框颜色
								//borderWidth: 1,//hover拐点边框大小
								
							  }
							},
						},
						{
							name: '次高板',
							data: getParamValues('zg2', arr),
							type: 'line',								
							symbolSize: 1,
							label: {
								normal: {
									show: true,
									position: 'bottom',
									offset:[-20,0],
									formatter:function(param){
										console.log(param.value);
										n2++;										
										return param.value + "连板：\r\n" + arr[n2 - 1]["mc2"];											
									},
									textStyle:{//拐点上标字体大小颜色
										align:'left',
										lineHeight:15,	
										color:'#FFF0F5',
										fontSize:'12',
									}	
								}
							},
							itemStyle: {
							  normal: {
								lineStyle: {
								type:'dashed', //'dotted'点型虚线 'solid'实线 'dashed'线性虚线
								  width: 1,
								  color: "#FF00FF"
								},
								color: "#FF00FF",
							  },
							  emphasis: {
								color: '#FF00FF'
							  }
							},
						}					
					]
				}					
				myChart.setOption(option);
			}
		</script>
	</body>
</html>